package Other.alibaba;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.Future;

/**
 * @Classname Main
 * @Description TODO
 * @Date 2021/6/27 20:12
 * @Created by ASUS
 */
public class Main {

    public static int getResult(int[] N, int x, int y) {
        assert N != null;
        assert x > 0;
        assert y > 0;
        int n = N.length;
        int expected_weight = (n * (n + 1)/2) * x;
        int d = Math.abs(x - y);
        System.out.println(d);
        int real_weight = 0;
        for (int i = 0; i < n; i++) {
            real_weight +=  N[i] * (i + 1);
        }
        int target = Math.abs(expected_weight - real_weight) / d;
        return target - 1;
    }

    public static void main(String[] args) {
        int[] N = {5,5,5,5,5,5,5,5,5,5,5,15,5,5,5,5,5,5,5,5,5,5,5,5};
        int expected_target = -1;
        for (int i = 0; i < N.length; i++) {
            if (N[i] == 15) {
                expected_target = i;
                break;
            }
        }
        System.out.println(getResult(N, 5,15) == expected_target);
    }

}
